package com.example.basesystem.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;

import javax.persistence.*;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.List;

/**
 * 菜单实体类
 */
@Data
@Entity
@Table(name = "sys_menu")
@TableName("sys_menu")
public class SysMenu implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 主键
     */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @TableId(type = IdType.AUTO)
    private Long id;

    /**
     * 父菜单ID
     */
    @Column(nullable = false)
    private Long parentId;

    /**
     * 菜单名称
     */
    @Column(length = 50, nullable = false)
    private String name;

    /**
     * 路由路径
     */
    @Column(length = 100)
    private String path;

    /**
     * 组件路径
     */
    @Column(length = 100)
    private String component;

    /**
     * 图标
     */
    @Column(length = 50)
    private String icon;

    /**
     * 排序
     */
    private Integer sort;

    /**
     * 类型(0:目录,1:菜单,2:按钮)
     */
    @Column(nullable = false)
    private Integer type;

    /**
     * 权限标识
     */
    @Column(length = 100)
    private String perms;

    /**
     * 状态(0:禁用,1:正常)
     */
    @Column(nullable = false)
    private Integer status;

    /**
     * 创建时间
     */
    @Column(nullable = false)
    private LocalDateTime createTime;

    /**
     * 更新时间
     */
    private LocalDateTime updateTime;

    /**
     * 是否删除(0:未删除,1:已删除)
     */
    @TableLogic
    @Column(nullable = false)
    private Integer isDeleted;
    
    /**
     * 子菜单列表
     */
    @TableField(exist = false)
    @Transient
    private List<SysMenu> children;
}